import { createBrowserRouter, Navigate } from "react-router-dom";
import LayoutWrapper from "./layouts";
import Home from "./pages/Home.tsx";
import About from "./pages/About.tsx";
import Contact from "./pages/Contact.tsx";
import NotFound from "./pages/NotFound.tsx";

// 通用路由配置
export const routes = [
  {
    path: "/",
    element: <LayoutWrapper />,
    children: [
      {
        index: true,
        element: <Home />,
      },
      {
        path: "about",
        element: <About />,
      },
      {
        path: "home",
        element: <Navigate to="/" replace />,
      },
      {
        path: "contact",
        element: <Contact />,
      },
      {
        path: "*",
        element: <NotFound />,
      },
    ],
  },
];

// 创建路由浏览器实例
export const router = createBrowserRouter(routes);

export default router;